<!-- 分享对话框HTML -->
<div class="modal fade" id="shareModal">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
        	<div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title"></h4>
		    </div>
            <div class="modal-body">
                <div class="text-center share">
                    
                    <div>
                        <h3>微信扫码预览</h3>
                    </div>
                    <div class="qrcode-section">
                        <div class="item">
                            <img src="/static/common/images/qrcode_preview.jpg" class="all"/>
                        </div>
                    </div>
                    
                    
                    <div class="url">
                        <div class="input-group all-url">
                            <span class="input-group-addon">url</span>
                            <input type="text" class="form-control all">
                            <span class="input-group-btn">
                              <button class="btn btn-warning" data-role="copy-url" type="button">复制</button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
$(function(){
    //复制文本
    $('[data-role="copy-url"]').click(function(e){
        var oInput = $(this).parent().parent().find('input');
        console.log(oInput);
        oInput.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        toast.success('复制成功', 'success');
    });
    
    // 预览按钮点击事件
    $('[data-target="#shareModal"]').click(function(e){
        var id = $(this).data('id');
        var title = $(this).data('title');
        $('#shareModal .modal-title').text(title);
        //新版url
        var all_qrcode_url = $(this).data('all-url');
        	all_qrcode_url = encodeURIComponent(all_qrcode_url);
        var all_qrcode_src = "{:url('api/qrcode/create')}?url=" + all_qrcode_url;
        //新版二维码地址
         $('#shareModal .modal-body img.all').attr('src',all_qrcode_src);
        //新版url地址
        var all_text_url = $(this).data('all-url');
        $('#shareModal .modal-body input.all').attr('value',all_text_url);
    });
});
</script>